package edu.gdkm.demo12.practice;

import java.util.HashSet;

public class Test {
    public static void main(String[] args) {
        //在HashSet中不能添加重复元素(Worker)
        HashSet<Worker> hashSet=new HashSet();
        Worker worker1=new Worker();
        worker1.setName("张三");
        worker1.setAge(18);
        worker1.setSalary(1000);
        Address addr=new Address();
        addr.setAddressName("广州市天河区xxx");
        addr.setZipCode("510001");
        worker1.setAddr(addr);
        Worker worker2=new Worker();
        worker2.setName("张三");
        worker2.setAge(18);
        worker2.setSalary(1000);
        Address addr2=new Address();
        addr2.setAddressName("广州市天河区xxx");
        addr2.setZipCode("510001");
        worker2.setAddr(addr2);
        Worker worker3=new Worker();
        worker3.setName("张三");
        worker3.setAge(18);
        worker3.setSalary(1000);
        Address addr3=new Address();
        addr3.setAddressName("广州市海珠区xxx");
        addr3.setZipCode("510501");
        worker3.setAddr(addr3);
        hashSet.add(worker1);
        hashSet.add(worker2);
        hashSet.add(worker3);
        for(Worker worker:hashSet){
            System.out.println(worker);
        }
    }
}
